package com.kabuda.blog.controller;

import com.kabuda.blog.service.CommentsService;
import com.kabuda.blog.vo.Result;
import com.kabuda.blog.vo.params.CommentParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author kabuda
 * @create 2023-01-18 14:42
 */
@Api(tags = "评论接口")
@RestController
@RequestMapping("/comments")
public class CommentsController {
    @Autowired
    private CommentsService commentsService;

    @ApiOperation("根据文章id获取相关评论")
    @GetMapping("/article/{id}")
    public Result getArticleComments(@PathVariable("id") String id) {
       Result result=commentsService.getArticleComments(id);
        return result;
    }

    @ApiOperation("评论")
    @PostMapping("/create/change")
    public Result comment(@RequestBody CommentParam commentParam){
        return commentsService.comment(commentParam);
    }
}
